
<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="UTF-8">
    <link href="/static/devtools30/layui/css/layui.css" rel="stylesheet" />
    <link href="/static/devtools30/css/devindexbase.css" rel="stylesheet" />
    <link href="/static/devtools30/layui-v2.5.6/ext/soulTable/soulTable.css" rel="stylesheet"/>

    <script src="/static/devtools30/js/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script src="/static/devtools30/layui/layui.all.js" type="text/javascript"></script>
    <script src="/static/devtools30/js/devtoolCommon.js" type="text/javascript"></script>
    <title>新增功能</title>
    <style>
        /*页面内边距*/
        .addwrap {
            padding: 30px;
        }
        /*按钮组边框*/
        .layui-btn-primary {
            border: 1px solid #C9C9C9!important;
        }
        /*输入框高度*/
        .addwrap .layui-input,
        .layui-select {
            height: 25px;
        }

        .addwrap .layui-input-block {
            min-height: 26px;
            margin-left: 30px;
        }

        .addwrap .layui-form-label {
            padding: 0;
            text-align: right;
            height: 26px;
            line-height: 26px;
            width: 80px;
        }
        .layui-form-radio>i {
            font-size: 17px !important;
        }
        .layui-form-radio {
            line-height: 12px !important;
        }
        .layui-form-radio * {
            font-size: 12px;
        }
        .layui-form-item .layui-form-checkbox[lay-skin=primary] {
            margin-top: 3px !important;
        }
        .layui-form-checkbox span {

            font-size: 12px !important;
        }
    </style>
</head>
<body>
    <div class="flex flex-jusity-start" id="tableDiv" style="height:100%;width: 100%;padding: 3px 0;">

        <div class="backgroundf">
            <table id="mygrid3" lay-filter="mygrid3"></table>
        </div>

        <div class="backgroundf" style="margin-left: 8px">
            <table id="mygrid4" lay-filter="mygrid4"></table>
        </div>


    </div>
</body>
<script>
    var grid3tableid;
    var grid3tablecode;

    var height = dlCommon.getWinHeight();
    var width=dlCommon.getWinWidth();


    layui.config({
        base: '/static/devtools30/layui-v2.5.6/ext/',// 第三方模块所在目录
        version: 'v1.5.10' // 插件版本号
    }).extend({
        soulTable: 'soulTable/soulTable',
        tableChild: 'soulTable/tableChild',
        tableMerge: 'soulTable/tableMerge',
        tableFilter: 'soulTable/tableFilter',
        excel: 'soulTable/excel',
        dltable: 'treegrid/dltable',
        treeGrid:'treegrid/treeGrid'
    });
    layui.use(['form', 'table', 'jquery','treeGrid','layer','soulTable','tree'], function(){
        $(function(){
            initEvent();
            getMetadataList();
        });
    });

    function closeWin(){
        dlCommon.closeParentLayer();
    }

    function initEvent(){

        layui.table.render({
            elem: '#mygrid3'
            ,height: height-20
            ,width:350
            ,size: 'sm' //小尺寸的表格
            ,page: false //开启分页
            ,cols: [
            [ //表头
                {field: 'xh', title: '序号', width:40,type:"numbers"}

                ,{field: 'name', title: '表名',filter:true, width:150,}
                ,{field: 'code', title: '表代码',filter:true, width:150}
            ]],
            filter: {
                bottom: false
            },
            done: function() {
                // 在 done 中开启
                layui.soulTable.render(this)
            }
        });

        //单击表格
        dlCommon.layerTableOn('mygrid3', function (obj) {
            grid3tableid=obj.data.tableid;
            grid3tablecode=obj.data.code;
            getFileddataList();
        });

        layui.table.render({
            elem: '#mygrid4'
            ,height: height-20
            ,width:width-350
            ,size: 'sm' //小尺寸的表格
            ,page: false //开启分页
            ,cols: [
            [ //表头
                { field: 'xh', title: '序号', width: '14%', fixed: 'left' },
                { field: 'fieldName', title: '中文名称', sort: true,filter:true, width: '32%' },
                { field: 'fieldCode', title: '字段代码', sort: true, filter:true, width: '32%', },
                // { field: 'fieldType', title: '字段类型', sort: true, width: '15%', },
                // { field: 'bz', title: '备注',  },
                { field: 'opear', title: '操作',width: '20%',templet: function(d){
                    var str="";

                    str += '<button type="button" onclick="saveData(\''+d.fieldCode+'\')" class="layui-btn layui-btn-normal layui-btn-xs layui_edit_btn">选择</button>';

                    return str;
                } }
            ]],
            filter: {
                bottom: false
            },
            done: function() {
                // 在 done 中开启
                layui.soulTable.render(this)
            }
        });
    }

    function saveData(fieldcode){
        parent.setValueOfId(grid3tablecode,fieldcode);
        closeWin();
    }

    function getMetadataList(){
        layui.table.reload("mygrid3",{
            url:"/DevtFormMetadataController/getAll",
            loading:true,
            where:{templeid:'[(${tempid})]'},
            done:function(){
                dlCommon.layerSelectTable("mygrid3")
                layui.soulTable.render(this)
            }
        });
    }

    function getFileddataList(){
        if(!grid3tableid){
            return;
        }
        var data={
            tableid:grid3tableid
        };
        layui.table.reload("mygrid4",{
            url:"/DevtModelMetadataFieldController/getAll",
            where:data,
            loading:true,
        });
    }

</script>

</html>